<?php
declare (strict_types=1);

namespace app\common\listener;

use app\common\cache\TheRedis;
use app\common\enum\RedisKeyEnum;

/**
 * 后台注释注释监听
 * Class AdminLogout
 * @package app\listener
 */
class AdminLogout
{
    /**
     * 事件监听处理
     * @return mixed
     */
    public function handle($admin_id)
    {
        //登录缓存
        $key = TheRedis::composite_cache_key(RedisKeyEnum::LOGIN_USER_IDS, sprintf("%s-%s", app('http')->getName(), "system"));
        $login_user_ids = cache($key);
        if (!empty($login_user_ids)) {
            unset($login_user_ids[$admin_id]);
            cache($key, $login_user_ids);
        }
    }
}
